package cn.kgc.service.impl;


import cn.kgc.dao.Dao_dyb;
import cn.kgc.dao.userDao_dyb;
import cn.kgc.pojo.*;
import cn.kgc.service.Service_dyb;
import com.github.pagehelper.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

@Service
public class ServiceImpl_dyb implements Service_dyb {
    @Resource
    private Dao_dyb dao_dyb;

    @Resource
    private userDao_dyb userDao;

    @Override
    public Page<Employment> selEmployment(String positionName, String positionSort, String registranTime, String expirationDate) {
        return dao_dyb.selEmployment(positionName,positionSort,registranTime,expirationDate);
    }

    @Override
    public List<Organization> getOrganization() {
        return dao_dyb.getOrganization();
    }

    @Override
    public List<Position_dyb> getPositionById(Integer departmentid) {
        return dao_dyb.getPositionById(departmentid);
    }

    @Override
    public Integer savePositionInfo(Employment_dyb employment) {
        return dao_dyb.savePositionInfo(employment);
    }

    @Override
    public Integer upPositionInfo(Employment_dyb employment) {
        return dao_dyb.upPositionInfo(employment);
    }

    @Override
    public Employment_dyb getEmploymentById(Integer employmentId) {
        return dao_dyb.getEmploymentById(employmentId);
    }

    @Override
    public List<Position_dyb> getPositionByOrgan(String allName) {
        return dao_dyb.getPositionByOrgan(allName);
    }

    @Override
    public Integer delEmployment(Integer employmentId) {
        return dao_dyb.delEmployment(employmentId);
    }

    @Override
    public Position_dyb getPosition(Integer positionId) {
        return dao_dyb.getPosition(positionId);
    }

    @Override
    public List<String> getPower(Integer id) {
        String powerString = userDao.getPowerById(id);
        String[] split = powerString.split("-");
        List<String> powerList = Arrays.asList(split);
        return powerList;
    }

    @Override
    public List<HasPower> getHasPower() {
        return userDao.getHasPower();
    }

    @Override
    public Boolean upHasPower(Integer id, String haspower) {
        Integer integer = userDao.upHasPower(id, haspower);
        if (integer>0){
            return true;
        }
        return false;
    }

    @Override
    public Boolean upPass(Integer id, String password) {
        Integer integer = userDao.upPass(id, password);
        if (integer>0){
            return true;
        }
        return false;
    }


}
